package com.zhangxin.designmode.designpattern.singleten;

import java.util.Objects;

/**
 * 懒汉式单例
 *
 * @author zhangxin
 * @date 2022/4/26
 */
public class Singleton2Demo {

    private static Singleton2Demo instance;

    public Singleton2Demo() {

    }

    private static synchronized Singleton2Demo getInstance() {
        if (Objects.isNull(instance)) {
            return new Singleton2Demo();
        }
        return instance;
    }
}
